
APP1 = libext4_utils.a
APP2 = make_ext4fs

OBJS1 = make_ext4fs.o ext4fixup.o ext4_utils.o allocate.o contents.o extent.o indirect.o uuid.o sha1.o wipe.o
OBJS2 = make_ext4fs_main.o $(APP1)

CFLAG = -Wall
IFLAG =
LFLAG =
LDFLAG =

ifdef INCSPARSE
IFLAG += -I$(INCSPARSE)
endif

ifdef LIBSPARSE
LDFLAG += $(LIBSPARSE)
endif

.PHONY: all clean

all: $(APP1) $(APP2)
ifneq ($(TARGET),)
	cp -raf $^ $(TARGET)
endif

$(APP1): $(OBJS1)
ifneq ($(LDFLAG),)
	$(AR) -x $(LDFLAG)
endif
	$(AR) cqs $@ *.o

$(APP2): $(OBJS2)
	$(CC) $(CFLAG) $(IFLAG) -o $@ $^

%.o: %.c
	$(CC) $(CFLAG) $(IFLAG) -c -o $@ $<

clean:
	rm -rf *.o *.a $(APP)